package com.qf.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.dao.BillsDao;
import com.qf.entity.BillType;
import com.qf.entity.Bills;
import com.qf.service.BillsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 徐老板
 * @date 2020/3/26   9:31
 */
@Service
public class BillsServiceImpl implements BillsService {


    @Resource
    private BillsDao billsDao;

    @Override
    public PageInfo<Bills> findAll(int pageIndex, int pageSize, int typeId, String beginTime, String endTime) {
        //service层这里的写法都是固定的

        PageHelper.startPage(pageIndex, pageSize);
        Map map=new HashMap();
        //因为分页相当于过滤器 所以这里只考虑除分页以外的参数
        map.put("typeId", typeId);
        map.put("beginTime", beginTime);
        map.put("endTime", endTime);

        List<Bills> billsList = billsDao.findAll(map);
        return new PageInfo<>(billsList);
    }

    @Override
    public List<BillType> findType() {
        List<BillType> typeList = billsDao.findType();
        return typeList;
    }
}
